package com.hb.trade.server.project.section.service.item;

import cn.hutool.core.util.ReflectUtil;
import com.hb.core.pojo.enums.CommonTypeEnum;
import com.hb.core.pojo.project.proj.entity.AbstractProject;
import com.hb.core.pojo.project.section.dto.BidSectionDTO;
import com.hb.trade.server.project.section.manager.BidSectionManager;
import org.fzzn.core.util.Enums;

import static com.hb.core.pojo.enums.ButtonStatusEnum.DONE;
import static com.hb.core.pojo.enums.ButtonStatusEnum.NONE;

/**
 * 标段操作台公共判断条件
 *
 * @author zhaojk
 * @since 2022/3/8 14:25
 */
public class CommonService {

    /**
     * 判断标段是否为指定的形式(公开或者邀请)
     *
     * @author zhaojk
     * @since 2021-9-15
     */
    public int equals(BidSectionDTO section, CommonTypeEnum commonType) {
        BidSectionManager sectionManager = section.to(BidSectionManager.class);
        AbstractProject project = sectionManager.getProjectInfo();
        if (project == null) {
            return NONE.getCode();
        }
        Object proCommonType = ReflectUtil.getFieldValue(project, "commonType");
        if (Enums.equals(commonType, proCommonType)) {
            return DONE.getCode();
        }
        return NONE.getCode();
    }

}
